#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int kInversePairs(int n, int k);

int main()
{
	return 0;
}

int kInversePairs(int n, int k)
{
	int* dp = calloc(k + 1, sizeof(int));
	int* dp_aux = calloc(k + 1, sizeof(int));
	int* f[2] = { dp, dp_aux };

	const int MOD = 1e9 + 7; dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		int *cur = f[i & 1], *pre = f[(i & 1) ^ 1];
		cur[0] = pre[0];
		for (int j = 1; j <= k; j++) {
			cur[j] = cur[j - 1] - (j - i >= 0 ? pre[j - i] : 0) + pre[j];
			if (cur[j] >= MOD) cur[j] -= MOD;
			else if (cur[j] < 0) cur[j] += MOD;
		}
	}

	int res = f[n & 1][k];
	free(dp);free(dp_aux);
	return res;
}
